Skip to content

Dict: gather dictionary values straight into a VarBinBuilder - #9098

Open
robert3005 wants to merge 1 commit into
rk/fsst-decode-into-builderfrom
rk/dict-gather-into-builder
Open

Dict: gather dictionary values straight into a VarBinBuilder#9098
robert3005 wants to merge 1 commit into
rk/fsst-decode-into-builderfrom
rk/dict-gather-into-builder

Conversation

@robert3005

@robert3005 robert3005 commented Jul 30, 2026

Copy link
Copy Markdown
Contributor

Materialize dictionary values straight into VarBinBuilder instead of copying

bits.for_each_set_index(|row| num_bytes += view(row).len() as usize);
builder.append_value_slices(
num_bytes,
bits.set_indices().map(|row| view(row).bytes(&buffers)),

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this should be for_each_set_index

@robert3005 robert3005 Jul 31, 2026

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done — append_dict_to_varbin no longer builds an index iterator at all. The byte total is summed with for_each_set_index and the copy now goes through a new VarBinBuilder::append_valid_slices, which takes a FnMut(usize) -> &[u8] and walks the valid rows a word at a time internally. The iterator-based append_value_slices is gone (in the base PR), so set_indices() is out of this path entirely.

@robert3005 robert3005 added the changelog/chore A trivial change label Jul 31, 2026
@robert3005
robert3005 marked this pull request as ready for review July 31, 2026 13:42
Appending a string dictionary to a builder went through `take_canonical`,
which first materializes the values at full logical length — allocating and
re-reading a views buffer proportional to the row count. The dictionary is
usually far smaller than the column, so resolving each code against it in place
skips that intermediate and leaves one `memcpy` per row.

The fast path indexes the codes and the dictionary's views and data buffers as
host slices, so `varbin_fast_path_is_host` gates it on residency; a
device-resident dictionary still takes the canonical route, where a device
kernel can serve it.

Signed-off-by: Robert Kruszewski <robert@spiraldb.com>
Signed-off-by: Robert Kruszewski <github@robertk.io>
@robert3005
robert3005 force-pushed the rk/dict-gather-into-builder branch from 91142df to c82aa58 Compare July 31, 2026 18:11
@codspeed-hq

codspeed-hq Bot commented Jul 31, 2026

Copy link
Copy Markdown

Merging this PR will degrade performance by 10.02%

❌ 1 regressed benchmark
✅ 1841 untouched benchmarks
⏩ 55 skipped benchmarks1

Warning

Please fix the performance issues or acknowledge them on CodSpeed.

Performance Changes

Mode Benchmark BASE HEAD Efficiency
Simulation take_map[(0.1, 0.5)] 998.3 µs 1,109.4 µs -10.02%

Tip

Investigate this regression by commenting @codspeedbot fix this regression on this PR, or directly use the CodSpeed MCP with your agent.


Comparing rk/dict-gather-into-builder (c82aa58) with rk/fsst-decode-into-builder (96d2f3d)

Open in CodSpeed

Footnotes

  1. 55 benchmarks were skipped, so the baseline results were used instead. If they were deleted from the codebase, click here and archive them to remove them from the performance reports.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

changelog/chore A trivial change

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant